# -*- coding: utf-8 -*-
# @Time : 2021/9/26 12:02
# @Author : 伟哥
# @Email : xw@gmail.com
# @File : condition.py
# @Project : api
import requests
def text_id(app_key='15D7D73FA13C1011736B45A7ACCC4235'):
    '''根据获取CMS文章列表接口，取文章id'''
    r = requests.post(url='http://hn216.api.yesapi.cn/?s=App.Wxmini_Adver.GetAdList', json={'app_key':app_key})
    return r.json().get('data')['items'][0]

def register_data(app_key='15D7D73FA13C1011736B45A7ACCC4235',username='xiao',password='123456'):
    '''
    根据注册接口来获取data
    :param app_key: app_key
    :param username: 用户名
    :param password: 密码
    :return: data字典
    '''
    r = requests.post(url='http://hn216.api.yesapi.cn/?s=App.User.RegisterExt', json={'app_key': app_key,'username':username,'password':password})
    return r.json().get('data')

def login_data(app_key='15D7D73FA13C1011736B45A7ACCC4235',username='xiao',password='123456'):
    '''
    根据登录接口来获取data
    :param app_key: app_key
    :param username: 用户名
    :param password: 密码
    :return: data字典
    '''
    r = requests.post(url='http://hn216.api.yesapi.cn/?s=App.User.LoginExt', json={'app_key': app_key,'username':username,'password':password})
    return r.json().get('data')

def user_delete(other_uuid,admin_uuid,admin_token,app_key='15D7D73FA13C1011736B45A7ACCC4235'):
    '''
    需要有管理员账号，并且有token，在用户管理设置中可以设置为管理员
    :param other_uuid: 要删除的用户uuid
    :param admin_uuid: 管理员uuid
    :param admin_token: 管理员登录后获取的token
    :param app_key: 主用户的app_key
    :return: self
    '''
    requests.post('http://hn216.api.yesapi.cn/?s=App.User.RemoveUserForAdmin', json={'other_uuid':other_uuid,'admin_uuid':admin_uuid,'admin_token':admin_token,'app_key':app_key})
